package socket.socketByOIO.service;

import java.io.IOException;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * Created by yangluhua on 2017/11/6 0006.
 */
public class OIOServer {
    private static final int SERVER_PORT = 30000;
    public static CrazyitMap<String,PrintStream> clients = new CrazyitMap<>();

    public void init(){
        try {
            ServerSocket ss = new ServerSocket(SERVER_PORT);
            while(true){
                Socket socket = ss.accept();
                new ServerThead(socket).start();
            }
        }catch (IOException ex){
            System.out.println("服务器启动失败，是否端口"+SERVER_PORT+"已被占用？");
        }
    }

    public static void main(String[] args) {
        OIOServer server = new OIOServer();
        server.init();
    }
}
